package com.wetsion.securityoauthdemo.rmsclient.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
import org.springframework.security.web.savedrequest.RequestCache;
import org.springframework.stereotype.Component;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author weixin
 * @version 1.0
 * @CLassName CustomSaveRequestSuccessHandler
 * @date 2019/3/7 9:36 PM
 */
//@Component
public class CustomSaveRequestSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler {


    @Override
    public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
        System.out.println(request.getRequestURI());
        getRedirectStrategy().sendRedirect(request, response, "/home");
    }
}
